using System;
using CStock;
using NUnit.Framework;

using System.Diagnostics;
namespace TestCases.Web
{
	/// <summary>
	/// Summary description for WebDownloadTest.
	/// </summary>
	[TestFixture] 
	public class WebDownloadTest
	{
		public WebDownloadTest()
		{
			
		}
		private void DownloadProgressCallback ( int bytesSoFar, int totalBytes )
		{
//			bytesDownloadedTextBox.Text = bytesSoFar.ToString("#,##0");
//
//			if ( totalBytes != -1 )
//			{
//				progressBar.Minimum = 0;
//				progressBar.Maximum = totalBytes;
//				progressBar.Value = bytesSoFar;
//				totalBytesTextBox.Text = totalBytes.ToString("#,##0");
//			}
//			else
//			{
//				progressBar.Visible = false;
//				totalBytesTextBox.Text = "Total File Size Not Known";
//			}
		}

		private void DownloadCompleteCallback ( byte[] dataDownloaded )
		{
            //dataDownloaded.GetValue(
//			if ( !progressBar.Visible )
//			{
//				progressBar.Visible = true;
//				progressBar.Minimum = 0;
//				progressBar.Value = progressBar.Maximum = 1;
//				totalBytesTextBox.Text = bytesDownloadedTextBox.Text;
//			}
//
//			MessageBox.Show("Download complete...", "Download Info" );
			//Debug.WriteLine(dataDownloaded.GetValue(.Text);
		}
		public void DownloadFile(string url)
		{
			WebDownload dl = new WebDownload();
			dl.DownloadUrl = url;
			dl.CompleteCallback += new DownloadCompleteHandler( DownloadCompleteCallback );
			dl.ProgressCallback += new DownloadProgressHandler( DownloadProgressCallback );

			System.Threading.Thread t = new System.Threading.Thread( 
				new System.Threading.ThreadStart(
				dl.Download ));
			t.Start();
			
		}
		[Test] 
		public void TestDownload()
		{
			DownloadFile("http://www.google.de");
		}
        [Test] 
        public void YahooIntraday()
		{
            string symbol = "SIE.DE";
            string id = "Siemens";
            IQuoteWeb qw = YahooFeedSockets.GetYahoo_Intraday(symbol, id);
            
			
		}
        [Test] 
        public void Consors()
        {
            string symbol = "SIE.DE";
            string wkn = "7236101";
            string id = "Siemens";
            //IDataItem di = new DataItem();
            //di.Symbol = "SIE.DE";
            //di.ID = "Siemens";
            //IDataItem MyData = (IDataItem)(this.programContext.TradeEconomy.Portfolio_Selected.DataItems)[i];
            IQuoteWeb qw = YahooFeedSockets.GetQuotes(wkn, symbol, id);
            //WriteItem(MyData.DataClass.Name, MyData.DataClass.ID, qw);

        }
        [Test]
        public void DowJones_ListOfStocks()
        {

            YahooFeedSockets.GetYahoo_ListOfStocks_UK("DJI");


        }
         [Test]
        public void DAX_ListOfStocks()
        {
            //WebQuotes.GetYahoo_ListOfStocks_UK("GDAXI");
            //WebQuotes.GetYahoo_ListOfStocks_DE("GDAXI");

        }
        [Test]
        public void Nasdaq_ListOfStocks()
        {
            YahooFeedSockets.GetYahoo_ListOfStocks_UK("IXIC");
        }
        [Test]
        public void FTSE_All_ListOfStocks()
        {
            YahooFeedSockets.GetYahoo_ListOfStocks_UK("FTAS");
        }
        [Test]
        public void EuroStoxx_All_ListOfStocks()
        {
            YahooFeedSockets.GetYahoo_ListOfStocks_UK("STOXX50E");
        }
        
        
	}
}
